package com.roncoo.education.config;

import com.roncoo.education.constants.CourseConstants;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 通用配置
 *
 * @author admin
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith("win")) {
            registry.addResourceHandler(CourseConstants.UPLOAD_RESOURCE_PATTERN).addResourceLocations(CourseConstants.UPLOAD_WINDOWS_RESOURCELOCATION);
        } else {
            registry.addResourceHandler(CourseConstants.UPLOAD_RESOURCE_PATTERN).addResourceLocations(CourseConstants.UPLOAD_LINUX_RESOURCELOCATION);
        }
    }


}
